<template>
	<div class="LayOut flex-row-c-c">
		<div class="echartItem" ref="echartItem"></div>
	</div>
</template>

<script>
	import * as echarts from 'echarts';
	export default {
		data() {
			return {
				option: null,
				myChart: null
			}
		},
		methods: {

		},
		created() {
			this.option = {
				title: {
					text: 'ECharts 入门示例'
				},
				tooltip: {},
				xAxis: {
					data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
				},
				yAxis: {},
				series: [{
					name: '销量',
					type: 'bar',
					data: [5, 20, 36, 10, 10, 20]
				}]
			}
		},
		mounted() {
			// console.log(this.$refs.echartItem)
			this.myChart = echarts.init(this.$refs.echartItem, 'dark')
			this.myChart.setOption(this.option)
			
		},
		beforeDestroy() {
			// console.log('销毁前');
			this.myChart.dispose()
			// console.log('已销毁');
		}
	}
</script>

<style lang="scss" scoped>
	.LayOut {
		width: 100%;
		min-height: 100vh;
		background-color: aqua;

		.echartItem {
			width: 300px;
			height: 300px;
			border: 1px solid black;
		}
	}
</style>